//
//  SYDOutOfTheCar.m
//  PinGJByOwnerSide
//
//  Created by lantaiyuan on 2017/8/16.
//  Copyright © 2017年 lantaiyuan. All rights reserved.
//

#import "SYDOutOfTheCar.h"
@interface SYDOutOfTheCar()
@property (weak, nonatomic) IBOutlet UILabel *startTimeLbl;
@property (weak, nonatomic) IBOutlet UILabel *endTimeLbl;
@property (weak, nonatomic) IBOutlet UILabel *startLocationLbl;
@property (weak, nonatomic) IBOutlet UILabel *endLocationLbl;
@property (weak, nonatomic) IBOutlet UIButton *clickBtn;

@end
@implementation SYDOutOfTheCar
- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self = [[NSBundle mainBundle]loadNibNamed:NSStringFromClass([SYDOutOfTheCar class]) owner:nil options:nil].lastObject;
        self.frame = frame;
    }
    return self;
}

-(void)awakeFromNib{
    [self.clickBtn setTitle:@"去接乘客  " forState:UIControlStateNormal];
    [super awakeFromNib];
    WEAKSELF
    [[self.clickBtn rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(__kindof UIControl * _Nullable x) {
        if (weakSelf.carBlock) {
            weakSelf.carBlock();
        }
    }];
}

- (void)setBtnTitle:(NSString *)title{
    [self.clickBtn setTitle:title forState:UIControlStateNormal];
}

- (void)setOrder:(YMOrder *)order{
    
    YMStation * firstSta = order.carpoolRoute.carpoolRouteStations.firstObject;
    YMStation * lastSta = order.carpoolRoute.carpoolRouteStations.lastObject;
    
    self.startTimeLbl.text = [NSString getHourMinuteWithString:[NSString stringWithFormat:@"%@",firstSta.arriveTime]];
    self.endTimeLbl.text  = [NSString getHourMinuteWithString:[NSString stringWithFormat:@"%@",lastSta.arriveTime]];
    self.startLocationLbl.text = firstSta.stationName;
    self.endLocationLbl.text = lastSta.stationName;
}
@end
